{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "7cc54b69",
   "metadata": {},
   "source": [
    "### 支持的模型名称\n",
    "\n",
    "模型名称替换代码中的 `model_name`变量的值。\n",
    "\n",
    "| **模型系列** | **模型名称**                                                 |\n",
    "| ------------ | ------------------------------------------------------------ |\n",
    "| AlexNet      | alexnet                                                      |\n",
    "| VGG          | vgg11, vgg11_bn, vgg13, vgg13_bn, vgg16, vgg16_bn, vgg19_bn, vgg19 |\n",
    "| ResNet       | resnet18, resnet34, resnet50, resnet101, resnet152, resnext50_32x4d, resnext101_32x8d, wide_resnet50_2, wide_resnet101_2 |\n",
    "| DenseNet     | densenet121, densenet169, densenet201, densenet161           |\n",
    "| Inception    | googlenet, inception_v3                                      |\n",
    "| SqueezeNet   | squeezenet1_0, squeezenet1_1                                 |\n",
    "| ShuffleNetV2 | shufflenet_v2_x2_0, shufflenet_v2_x0_5, shufflenet_v2_x1_0, shufflenet_v2_x1_5 |\n",
    "| MobileNet    | mobilenet_v2, mobilenet_v3_large, mobilenet_v3_small         |\n",
    "| MNASNet      | mnasnet0_5, mnasnet0_75, mnasnet1_0, mnasnet1_3              |\n",
    "| ViT       | ViT, SimpleViT, CrossFormer,TwinsSVT|\n",
    "\n",
    "![](http://medai.icu/storage/attachments/2023/10/10/RHd9eH5U67VsOP8vqyNyBD5nGYREejkAKx3Jw16X.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b11e3135",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "from onekey_algo.classification.run_classification import main as clf_main\n",
    "from collections import namedtuple\n",
    "from onekey_algo import get_param_in_cwd\n",
    "\n",
    "# 设置参数\n",
    "for model_name in ['CrossFormer', 'resnet18']:\n",
    "    train_f = r'你自己的训练集文件train.txt'\n",
    "    val_f = r'你自己的测试集文件val.txt'\n",
    "    labels_f = r'labels.txt'\n",
    "    data_pattern = r'多通道npy文件目录'\n",
    "\n",
    "    params = dict(train=train_f,\n",
    "                  valid=val_f,\n",
    "                  labels_file=labels_f,\n",
    "                  data_pattern=data_pattern,\n",
    "                  j=4,\n",
    "                  max2use=None,\n",
    "                  val_max2use=None,\n",
    "                  batch_balance=False,\n",
    "                  normalize_method='imagenet',\n",
    "                  model_name=model_name,\n",
    "                  vit_settings = {'patch_size': 64, 'dim': 1024, 'depth': 6, 'heads': 16, 'mlp_dim': 2048},\n",
    "                  gpus=[0],\n",
    "                  batch_size=16,\n",
    "                  epochs=1,\n",
    "                  init_lr=0.001,\n",
    "                  optimizer='sgd',\n",
    "                  retrain=r'',\n",
    "                  model_root= 'models',\n",
    "                  iters_start=0,\n",
    "                  iters_verbose=2,\n",
    "                  save_per_epoch=True,\n",
    "                  add_date=False,\n",
    "                  in_channels=6,\n",
    "                  pretrained=False)\n",
    "    # 训练模型\n",
    "    Args = namedtuple(\"Args\", params)\n",
    "    clf_main(Args(**params))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "82461f7e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
